Re: Perl and AutoCommit - Mailing list pgsql-general

From Dan Sugalski
Subject Re: Perl and AutoCommit
Date
Msg-id a06210201be6c133449d2@[192.168.0.8]
Whole thread Raw
In response to Re: Perl and AutoCommit  (Madison Kelly <linux@alteeve.com>)
List pgsql-general
At 1:34 AM -0500 3/27/05, Madison Kelly wrote:
>Dan Sugalski wrote:
>>At 12:31 AM -0500 3/27/05, Madison Kelly wrote:
>>
>>>Hi all,
>>>
>>>   After looking at the postres and perl docs plus some Googling I
>>>can't seem to find the answer I am looking for. I hope maybe
>>>someone here can help. ^_^
>>>
>>>   What I am trying to do is turn off autocommit for one particular
>>>task in my program. I realize I can turn off AutoCommit when I
>>>connect to the database but in this case that is not what I want
>>>to do. This is a one-off task.
>>
>>
>>Set the AutoCommit attribute of the database handle. Pull up the
>>docs for DBI and search for the "Database Handle Attributes"
>>section.
>
>Hmm... I've read that now (thank you!) and I have added:
>
>$acw=$DB->{AutoCommit};
>print " |- AutoCommit was: [$acw]\n";
>$DB->{AutoCommit} = 0 || die...
>$acn=$DB->{AutoCommit};
>print " |- AutoCommit now: [$acw]\n";
>$DB->begin_work() || die...
>#lot of transactions
>$DB->commit() || die...
>
>For some reason though my program dies on the '$DB->{AutoCommit}=0 ...' line.

Well.. yeah. Assignment's an expression, with a value of the right
hand side of the expression. Since the assignment part of the logical
or is false, the right hand side's evaluated and you die, not because
anything failed.

The docs say it's a fatal error to use an unsupported value, so I'd
assume it actually dies and you'd need to trap with eval.
--
                Dan

--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk

pgsql-general by date:

Previous
From: "Guy Rouillier"
Date:
Subject: Re: Command prompt window (8.0)
Next
From: Tom Lane
Date:
Subject: Re: Major Performance issue